package com.wandian.texas;

import java.util.concurrent.TimeUnit;

import com.wandian.util.Log;

/**
 * 调用SessionMgr里的Mainprocess扫描
 * 
 * @author long
 * @date 2012-10-1 下午3:38:49
 * @qq 108232706
 * @description ThreadRun
 */
public class ThreadRun extends Thread {
	private boolean isRun;
	private int count;
	public short status = 0;
	private final SessionMgr sessionMgr;

	public boolean isRun() {
		return isRun;
	}

	public void setRun(boolean isRun) {
		this.isRun = isRun;
	}

	public ThreadRun(SessionMgr _sessionMgr) {
		super("CallMainProcess");
		this.sessionMgr = _sessionMgr;
	}

	@Override
	public void run() {
		while (isRun) {
			if (status == 0) {
			try {
				sessionMgr.MainProcess();
			} catch (Throwable e) {
				e.printStackTrace();
			}
			}
			try {
				TimeUnit.MILLISECONDS.sleep(1);
			} catch (InterruptedException e) {
				Log.info("MainProcess InterruptedException了");
			}
		}
		Log.info("MainProcess退出了");
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}
}